package com.usian.article.controller;

import com.usian.apis.article.ArticleHomeControllerApi;
import com.usian.article.service.ApArticleService;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController implements ArticleHomeControllerApi {

    @Autowired
    private ApArticleService apArticleService;

    public static final int LOADTYPE_LOAD_MORE = 1; //上拉更多
    public static final int LOADTYPE_LOAD_NEW = 2;  //下拉最新

    /**
     * app端文章默认查询列表
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(LOADTYPE_LOAD_MORE,dto);
    }

    /**
     * app端文章默认查询更多
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(LOADTYPE_LOAD_MORE,dto);
    }

    /**
     * app端文章默认查询最新
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(LOADTYPE_LOAD_NEW,dto);
    }
}
